//
//  EditPayDepositApi.m
//  EMMApp
//
//  Created by YangLiang on 16/5/26.
//  Copyright © 2016年 YiXun. All rights reserved.
//

#import "EditPayDepositApi.h"
#define myUrlMethod @"editPayDeposit"
#define myUrlPath @"/appapi/editPayDeposit"
@implementation EditPayDepositApi
{
    NSString *_body;
}
- (instancetype)initWithPayDepositId:(NSString *)payDepositId
                        isPayDeposit:(NSString *)isPayDeposit
                              roomId:(NSString *)roomId
                       calculateArea:(NSString *)calculateArea
                       discountPrice:(NSString *)discountPrice
                  discountTotalPrice:(NSString *)discountTotalPrice
                      payDepositCode:(NSString *)payDepositCode
                     payDepositMoney:(NSString *)payDepositMoney
                             agentId:(NSString *)agentId
                      payDepositDate:(NSString *)payDepositDate
                              remark:(NSString *)remark
                         auditStatus:(NSString *)auditStatus
                          memberName:(NSString *)memberName
                        documentType:(NSString *)documentType
                      documentNumber:(NSString *)documentNumber
                              mobile:(NSString *)mobile
                            mailPost:(NSString *)mailPost
                            postcode:(NSString *)postcode
                  customerFamilyList:(NSArray *)customerFamilyList
                           imageList:(NSMutableArray *)imageList {
    
    self = [super init];
    if (self) {
        NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
        NSString *merchantId = [userdf objectForKey:@"merchantId"];
        NSString *userId = [userdf objectForKey:@"userNameId"];
        NSString *token = [userdf objectForKey:@"is_login"];
        NSString *projectCode = [userdf objectForKey:@"projectCode"];
        
        NSMutableDictionary *params = [NSMutableDictionary dictionary];
        [params setValue:apiVersion forKey:@"version"];
        [params setValue:[IDTools devId2] forKey:@"terminalCode"];
        [params setValue:merchantId forKey:@"merchantId"];
        [params setValue:userId forKey:@"userId"];
        [params setValue:token forKey:@"token"];
        [params setValue:projectCode forKey:@"projectCode"];
        [params setValue:payDepositId forKey:@"payDepositId"];

        [params setValue:isPayDeposit forKey:@"isPayDeposit"];
        [params setValue:roomId forKey:@"roomId"];
        [params setValue:calculateArea forKey:@"calculateArea"];
        [params setValue:discountPrice forKey:@"discountPrice"];
        [params setValue:discountTotalPrice forKey:@"discountTotalPrice"];
        [params setValue:payDepositCode forKey:@"payDepositCode"];
        [params setValue:payDepositMoney forKey:@"payDepositMoney"];
        [params setValue:agentId forKey:@"agentId"];
        [params setValue:payDepositDate forKey:@"payDepositDate"];
        [params setValue:remark forKey:@"remark"];
        [params setValue:auditStatus forKey:@"auditStatus"];
        [params setValue:memberName forKey:@"memberName"];
        [params setValue:documentType forKey:@"documentType"];
        [params setValue:documentNumber forKey:@"documentNumber"];
        [params setValue:mobile forKey:@"mobile"];
        [params setValue:mailPost forKey:@"mailPost"];
        [params setValue:postcode forKey:@"postcode"];
        [params setValue:customerFamilyList forKey:@"customerFamilyList"];
        [params setValue:imageList forKey:@"imageList"];
        
        _body = [@{@"params" : params} JSONString];
        NSLog(@"%@:\n %@%@?body=%@", myUrlMethod, apiBaseUrl, myUrlPath, _body);
    }
    return self;
}

#pragma mark - 父类继承拓展

- (NSString *)requestUrl
{
    return myUrlPath;
}

- (id)requestArgument
{
    return @{ @"body" : _body };
}

- (NSString *)methodString
{
    return myUrlMethod;
}


#pragma mark - 通用

- (EditPayDeposit *)resultData
{
    id myObj = [IDTools jsonStrToObjc:self.responseString method:myUrlMethod];
    
    EditPayDeposit *data = (EditPayDeposit *)myObj;
    
    NSLog(@"%@ resultData is %@", myUrlMethod, data);
    
    return data;
}

- (BOOL)isSuccess
{
    NSString *str = [[self resultData] result];
    if ([NSString isStringEmpty:str] || ![str isEqualToString:@"1"]) {
        return NO;
    } else {
        return YES;
    }
}

@end
